package jw3.c2.controller;

import jw3.c2.model.Rooms;
<<<<<<< HEAD
import jw3.c2.model.Rooms_type;
=======
>>>>>>> c99b46d54f58d393ceec8deeb74a45150477d89f
import jw3.c2.utils.DBConnection;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
<<<<<<< HEAD
import java.util.List;
=======
>>>>>>> c99b46d54f58d393ceec8deeb74a45150477d89f
import java.util.Vector;

public class RoomsController {


<<<<<<< HEAD
    //增
    public static boolean register(Rooms rooms) {

        return true;
    }

    //删
    public boolean logOut(int id) {
        return true;
    }

    //改
    public boolean edit(Rooms rooms) {
        return true;
    }

    //全查
    public static Vector<Vector<Object>> getAll() {
        //sql 语句
        String sql = "select * from rooms";
        //1、构造Vector类型用于赋值给表格
        Vector<Vector<Object>> data2=new Vector<Vector<Object>>();
        try {
            Connection conn = DBConnection.getConnection();
            PreparedStatement ps = conn.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            while (rs.next()){
                //创造对象，每次放一条数据
//                UserInfo ui=new UserInfo();
                Vector<Object>R =new Vector<Object>();

                //将每个字段放入对象
                R.add(rs.getInt("Rooms_ID"));
                R.add(rs.getInt("Rooms_Num"));
                R.add(rs.getInt("Rooms_Type_ID"));
                R.add(rs.getString("Rooms_State"));
                R.add(rs.getString("Rooms_Area"));
                R.add(rs.getString("Rooms_Phone"));
                R.add(rs.getString("L_ID"));

                //每次将一条数据加入到集合
                data2.add(R);
            }
            DBConnection.close(rs,ps,conn);
            return data2;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
=======

        //增
        public static boolean register(Rooms rooms) {

            return true;
        }

        //删
        public boolean logOut(int id) {
            return true;
        }

        //改
        public boolean edit(Rooms rooms) {
            return true;
        }

        //全查
        public static Vector<Vector<Object>> getAll() {
            //sql 语句
            String sql = "select * from rooms";
            //1、构造Vector类型用于赋值给表格
            Vector<Vector<Object>> data2=new Vector<Vector<Object>>();
            try {
                Connection conn = DBConnection.getConnection();
                PreparedStatement ps = conn.prepareStatement(sql);
                ResultSet rs = ps.executeQuery();
                while (rs.next()){
                    //创造对象，每次放一条数据
//                UserInfo ui=new UserInfo();
                    Vector<Object>R =new Vector<Object>();

                    //将每个字段放入对象
                    R.add(rs.getInt("Rooms_ID"));
                    R.add(rs.getInt("Rooms_Num"));
                    R.add(rs.getInt("Rooms_Type_ID"));
                    R.add(rs.getString("Rooms_State"));
                    R.add(rs.getString("Rooms_Area"));
                    R.add(rs.getString("Rooms_Phone"));
                    R.add(rs.getString("L_ID"));

                    //每次将一条数据加入到集合
                    data2.add(R);
                }
                DBConnection.close(rs,ps,conn);
                return data2;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    }
>>>>>>> c99b46d54f58d393ceec8deeb74a45150477d89f
